package com.qh.physicsexperiment.utils;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.injector.methods.Insert;
import com.baomidou.mybatisplus.core.injector.methods.Update;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.Null;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)   //父类属性不参与equal
@Accessors(chain = true)    //set方法返回对象
public class BaseEntity implements Serializable {
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
//    /**
//     * 自增id
//     */
//    @ApiModelProperty(value = "自增id")
//    @TableId(type = IdType.AUTO)
//    private Integer id;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)//插入时填充
    //https://blog.csdn.net/m0_50911560/article/details/129829921
    @Null(groups = {Insert.class, Update.class}, message = "创建时间不用传")
    private Date createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @Null(groups = {Insert.class, Update.class}, message = "修改时间不用传")
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)//INSERT_UPDATE: 插入和更新时都填充
    private Date updateTime;
}
